package com.example.productservice.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ProductController {
    @GetMapping("/products/{productId}")
    public String getProductInfo(@PathVariable("productId") Long productId,
                                 @RequestHeader(value = "X-Request-Source", defaultValue = "unknown") String source) {
        String productName = "Product-" + productId;
        return String.format("商品名称: %s (来自 %s 的请求)", productName, source);
    }
}    